package com.rjxy.plansystemmanagement.mapper;

import com.rjxy.plansystemmanagement.entity.yh.YhCode;
import com.rjxy.plansystemmanagement.entity.yh.YhCoupon;
import com.rjxy.plansystemmanagement.entity.yh.YhUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface YhMapper {
    @Select("select * from yh_coupon where status=2")
    List<YhCoupon> getIssuedCoupon();

    @Insert("insert into yh_user(user_id,coupon_id,status) values (#{user_id},#{coupon_id},#{status})")
    void addYhUser(YhUser yhUser);

    List<YhCoupon> getCouponByUid(Integer id);

    @Select("select * from yh_code where code = #{code}")
    YhCode selectCode(String code);

    @Update("update yh_code set user_id = #{user_id} where id = #{id}")
    void updateYhCode(YhCode yhCode);

    @Select("select * from yh_user where status = #{status}")
    List<YhUser> getYhUserByStatus(Integer status);

    @Select("select * from yh_coupon where id = #{id}")
    List<YhCoupon> getCouponsByCouponId(Integer id);

    void updateYhUser(YhUser yhUser);
}
